package org.hbkj.springbootmybatis.utils;

import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String msg;    // 保持与控制器中一致的字段名
    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> res = new Result<>();
        res.code = 0;
        res.msg = "成功";  // 保持与控制器中一致的字段名
        res.data = data;
        return res;
    }

    public static <T> Result<T> error(String msg) {
        Result<T> res = new Result<>();
        res.code = 1;
        res.msg = msg;   // 保持与控制器中一致的字段名
        return res;
    }
}